﻿using Microsoft.AspNetCore.Http;

namespace ApiTemplate.Common
{
    public class CurrentUser: ICurrentUser
    {
        private readonly IHttpContextAccessor httpContextAccessor;

        public CurrentUser(IHttpContextAccessor httpContextAccessor)
        {
            this.httpContextAccessor = httpContextAccessor;
            string token = this.httpContextAccessor.HttpContext?.Request?.Headers["UserToken"];
            if (token.IsNotNullOrEmpty())
            {
                IsLogin = true;
                Token = token;
                UserName = "从token获取用户";
                UserId = "89757";
                //可以从token获取用户
            }
        }

    }
}
